""" 
读写取esp32 rtc时间
"""

from machine import RTC
import time

rtc = RTC()


def read_rtc_datetime():
    # 读取时间
    date_time = rtc.datetime()
    buf = "%d-%d-%d %d:%d:%d" % (
        date_time[0],
        date_time[1],
        date_time[2],
        date_time[4],
        date_time[5],
        date_time[6],
    )
    return buf


if __name__ == "__main__":
    print(read_rtc_datetime())
    rtc.datetime((2050,8,10,2,10,20,58,0))
    print(read_rtc_datetime())
